home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Hyper / T / ToolKit Help 5.0.1.sit / ToolKit™ Help / ToolKit™ Help.rsrc / TEXT_802_TKpopMenu.txt < prev    next >
Encoding:
Text File  |  1994-05-05  |  9.4 KB  |  251 lines

  1. TKpopMenu
  2.  
  3.       XFCN,MDEF
  4.       No. 4406
  5.       Version:  5.0 (ONLY for Registered owners of ToolKit‚Ñ¢)
  6.       Copyright ¬© 1990 - 1994 by Stan Gilbert
  7. _____________________________________________________
  8.  
  9. TKpopMenu creates popUp menus from unlimited TEXT resources, or from a HyperCard‚Ñ¢ container, or from real MENU resources.  Supports hierarchical menus, ICONS, reduced ICONs, SICNs (small icons), special FONT, FONT Size, and resource menus.  It will also create PICTure type menus.
  10.  
  11.                          ∂
  12. Examples
  13.  
  14. √ì√ä‚Ǩget TKpopMenu("Animals")
  15. √ä√äÔ¨Çget TKpopMenu("Animals",left of me,bottom of me)
  16. √ä√äÔ¨Çget TKpopMenu("Animals",the mouseH, the mouseV)
  17. √ä√äÔ¨Çget TKpopMenu("XCMDs,
  18. "&return,"","","true")
  19.  
  20.  
  21. Parameters
  22.  
  23. √ì‚Ä∫get TKpopMenu ("myMenu")
  24.  
  25. Parameter 1
  26.  
  27. name:  name of menu resource for the appropriate type of menu (TEXT, PICT, MENU).  If this is left empty then it is assumed the item list is literal and passed in the 5th parameter.
  28.  
  29. √ì‚Ä∫get TKpopMenu ("myMenu", left of me + 1)
  30.  
  31. Parameter 2
  32.  
  33. LEFT:  left postition of menu.  If it is "" then the default is left of target
  34.  
  35. √ì‚Ä∫get TKpopMenu ("myMenu", left of me + 1, bottom of me)
  36.  
  37. Parameter 3
  38.  
  39. TOP:  top position of menu.  If it is "" then the default is bottom of target
  40.  
  41. Parameter 4
  42.  
  43. cmd:  a list of the following appropriate commands, separated by commas, and enclosed in quotes.  Not case sensitive.
  44.  
  45. For TEXT menus:
  46. ¬†menu:  specify use of a MENU type resource of the specified 
  47. ¬†¬†¬†¬†Ô¨Å‚Äπname in parameter 1
  48. ¬†sort:  sort the item list
  49.  
  50. For PICT menus:
  51.  
  52. √ì‚Ä∫get "pict,across3,down1,cellH75,cellW75,loc"
  53. ¬†Ô¨Ç‚ǨGet TKpopMenu("pMenu",left of me - 1,bottom of me - 1,it)
  54.  
  55. ¬†pict:  specify use of a PICT type resource of the specified 
  56. ¬†¬†¬†Ô¨Ç‚Ä∫name in parameter 1
  57. ¬†across + number:  how many PICT menu cells across
  58. ¬†down + number:  how many PICT menu cells down
  59. ¬†cellH + number:  height of each cell
  60. ¬†cellW + number:  width of each cell
  61.  
  62. For ALL menus:
  63. ¬†loc:  use local coordinates.
  64.  
  65. Parameter 5
  66.  
  67. itemList:  This is the item list from a HyperCard‚Ñ¢ container.  It is useful for modifying the item list before the menu is shown.  For instance, you can fetch a basic item list from a TEXT resource using TKdoTEXT, modify it by enabling/disabling items, adding check marks, etc. and then passing the list to TKpopMenu.
  68.  
  69.  
  70.  
  71. ‚Ä¢ Requirements
  72. __________________________________________________
  73.  
  74. √ì√äTKpopMenu has no special requirements that would provoke the dreaded ƒ±.  If the item list is missing you will get a "Beep" when you try to use the menu and if any ICONs or SICNs  required in the menu are missing they simply will not show up on the menu.
  75.  
  76. √ì√äTKpopMenu MUST be used in a mouseDOWN handler because menu handling is performed when the user clicks and holds the mouse button DOWN.
  77.  
  78.  
  79.  
  80. ‚Ä¢ Return Values
  81. __________________________________________________
  82.  
  83. √ì√äreturns MenuNAME,ItemNAME
  84.  
  85. MenuName  FIRST ITEM - hierarchical menus only
  86. ItemName  SECOND ITEM - ALWAYS item name selected
  87.  
  88.    Nothing selected        ""
  89.    Non Hierarchical item   ",itemName"
  90.    Hierarchical item       "menuName,itemName"
  91.  
  92. In BOTH cases where a selection was made a COMMA "," was in the result so that the ITEM selected is ALWAYS the second item of the result.
  93.  
  94.  
  95.  
  96. ‚Ä¢ Related Topics
  97. __________________________________________________
  98.  
  99. √ì√äSee TKdoTEXT (for creating TEXT resources).  NOTHING manages popUp menus faster or more efficiently than the ToolKit‚Ñ¢ TEXT Resource Editor.
  100.  
  101. SEE:  Menus tutorial included with ToolKit‚Ñ¢ for a complete explanation of using popUp menus with many examples and scripting tips.
  102.  
  103.  
  104.  
  105.  
  106. ‚Ä¢ Special Features
  107. __________________________________________________
  108.  
  109. √ì√äThere are a couple of unique features in this XFCN.  First, you do not normally pass an item list to this XFCN.  Instead, you pass the name of a TEXT resource in the stack.
  110.  
  111. Secondly, TKpopMenu returns what you select.  That means you will not have to modify your handler for the menu items if you edit the item list.
  112.  
  113. Another unique feature is the ability to create a menu list of ANY resource type in your stack.  For instance:
  114.  
  115. ÊÊÊTEXT,
  116.  
  117.  
  118. you will get a hierarchical menu item called TEXT with a sorted submenu of all the 'TEXT' resources in the stack.  That strange looking character (the box) following the comma is option/shift 'R' for Resource.
  119.  
  120.  
  121. ‚Ä¢ PICT Type Menus
  122.  
  123. √à√äTKpopMenu allows you to create PICTure type menus.  This is done by sending certain specifiers to TKpopMenu.  A PICT type menu consists of a number of cells, all of which must be equal in size.  They do NOT have to be square, that is, equal on all sides.  Rectangles are permitted, but, they all must be the same size.  The only limit to the number of cells is a practical one which is the screen size.  The steps to using these menus are as follows:
  124.  
  125. 1. Create a graphic (picture) of the menu the way you want to see it.  The PICT should be composed of a number of equal sized cells, or rectangles.  Color the PICT if you want.
  126.  
  127. 2. Copy the inner contents of the PICTure and store it as a PICT resource in your stack.  Remember, the menu itself will frame the picture, so, you want to copy the contents of the PICTure just inside the overall border of your PICTure.  Make sure the PICT resource has a name.
  128.  
  129. 3. Now you can call TKpopMenu with the following specifiers:
  130.  
  131. PICT,ACROSSn,DOWNn,CELLWn,CELLHn   where
  132.  
  133. PICT commands TKpopMenu to create a PICT type menu
  134. ACROSSn specifies n cells ACROSS
  135. DOWNn specifies n cells DOWN
  136. CELLWn specifies cells of n width (actual outside width - 1)
  137. CELLHn specifies cells of n height (actual outside height - 1)
  138.  
  139. The commands are not case sensitive and the commas are not necessary.
  140.  
  141. √äÀÜ√äCLICK HERE to see an illustration of this.
  142.  
  143.  
  144. ¬†m¬†CLICK AND HOLD to see Menu1
  145.  
  146. The script might look like this:
  147.  
  148.   on mouseDown
  149.     get "pict,across3,down1,cellw124,cellh124"
  150.     get TKpopMenu("myPICTname","","",it)
  151.     if it = "" then exit to hyperCard
  152.     if it = 1 then
  153.       -- process "No Preppies"
  154.     else if it = 2 then
  155.       -- process "No Smoking"
  156.     else if it = 3 then
  157.       -- process "No Nukes"
  158.     end if
  159.   end mouseDown
  160.  
  161.  
  162. √ì√äWhat is returned is the number of the cell selected, from left to right and top to bottom.
  163.  
  164. √à√äYou can use two or more menu PICTs to show some intermediate result.  The PhoneBook stack provided with ToolKit‚Ñ¢ illustrates this.  One of the things the control menu allows you to do is insert notes for any given name.  If no notes exist the menu appears with an empty document representing the hidden note field for a name.  This is illustrated by the following example:
  165.  
  166. ¬†m¬†CLICK AND HOLD to see Menu2
  167.  
  168. Once notes are posted to a name the menu will have a document with writing in it, like this:
  169.  
  170. ¬†m¬†CLICK AND HOLD to see Menu3
  171.  
  172. The name of the PICT to use is simply changed as according to the contents of the field used to hold notes.  The part of the script that does this looks like this:
  173.  
  174.   ‚Ä¢
  175.   ‚Ä¢
  176.         
  177.   get "pict,across3,down1,cellH75,cellW75"
  178.   if bg fld "Notes" = "" then
  179.     get TKpopMenu("Menu1","","",it)
  180.   else
  181.     get TKpopMenu("Menu2","","",it)
  182.   end if
  183.         
  184.   ‚Ä¢
  185.   ‚Ä¢
  186.  
  187.  
  188. More Information
  189.  
  190. √ì√äMeta-characters are special characters inserted before items that allow the display of ICONs, SICNs, different font styles, cmd key equivalents.  Meta-characters are always followed by another character to further define the modification.
  191.  
  192. Meta-character Features
  193.  
  194. (√ä‚ÅÑDisables, or dims, an item.
  195. /√ä‚ÅÑCmd Key equivalent - "Quit/Q" yields "Quit‚İÀöQ"
  196. !√ä‚Ǩputs character following it before the item as a check
  197.       mark.  Use "Key Caps" DA to locate checkmark (ctl R)
  198.       to copy/paste
  199. ~ԨǂÄ∫followed by id of SICN (257 to 511)
  200. ^    followed by id of ICON (257 to 511)
  201. >    followed by id of ICON to be reduced (257 to 511)
  202. <    followed by character to set text style to:
  203.  
  204.          B  Bold
  205.          I  Italic
  206.          U  UnderLine
  207.          O  Outline
  208.          S  Shadow
  209.  
  210.  
  211.  
  212. ‚Ä¢ Beyond the Toolbox - Resource Menus
  213. __________________________________________________
  214.  
  215. TKpopMenu goes beyond the toolbox.  Suppose we wanted a list of all ICONs and XCMDs to show up in a hierarchical menu.
  216.  
  217. ÊÊÊÊÊICONs,
  218.  
  219. ÊÊÊÊÊXCMDx,
  220.  
  221.  
  222. The little box following each item is an option/shift "R" (for 'Resource').  It directs TKpopMenu to build a sorted submenu of all available resources of the specified type IN THE CURRENT STACK.
  223.  
  224. The first four characters of the menu item MUST match EXACTLY the name of a class of resources (ie. Icon is not ICON).  It is case sensitive.  Resource types are always four characters long.  TKpopMenu does not care what follows the first four characters (notice the small "s" after ICON).  The option/shift 'R' tells TKpopMenu to compile a SORTED list of all the resources of type ICON into a hierarchical submenu.
  225.  
  226. See Inside Macintosh‚Ñ¢ volume 1 page 107 for information on resource types.
  227.  
  228.  
  229. ‚Ä¢ Fonts
  230.  
  231. Fonts are a special case:
  232.  
  233. ÊÊÊÊÊFONTs,
  234.  
  235.  
  236. The little box here is an option/shift "F" because we want TKpopMenu to build a menu of ALL available FONTs including the System, HyperCard, Home, and the current stack.  Option/shift "R" would only show fonts in the current stack.
  237.  
  238. Another unique TKpopMenu feature is FONT sizes.
  239.  
  240. ÊÊÊÊÊSize,
  241.  
  242.  
  243. The "special character" in this case is an option/shift "S".  This will create a size menu for fonts and outline the sizes available for the currently selected font.
  244.  
  245. See TKresFile for resources in another stack.
  246.  
  247.  
  248.  
  249.  
  250. ‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû‚àû
  251.